<?php 
	class ControllerMemoryKnowledgeexam extends Controller {
		private $error = array();
		public function index() {
			// $user_id = $this->session->data['user_id'];
			// $this->cache->delete("allComplate".$user_id);
			$this->document->setTitle("knowledgeexam");
			$this->document->addStyle('admin/view/stylesheet/knowledgeexam.css');
			$this->document->addStyle('admin/view/stylesheet/animate.css');
			$this->document->addScript('admin/view/javascript/jquery.fittext.js');
			$this->document->addScript('admin/view/javascript/jquery.lettering.js');
			$this->document->addScript('admin/view/javascript/jquery.textillate.js');
			$data['maincontent'] = "知识点考评";
			if($this->request->server['REQUEST_METHOD'] == 'POST') {
				$results = $this->cache->get("allComplate".$user_id);
				if(empty($results)){
					$this->load->model('knowledge/knowledge');
					$today = date("Y-m-d");//"2017-03-01";//
					$starttime = $today." 00:00:01";
					$endtime = $today." 23:59:59";
	                $args = array(
	                		"user_id" =>$this->session->data['user_id'],
	                		"todaystarttime" => $starttime,
							"todayendtime" => $endtime
	                	);
	                $results = $this->model_knowledge_knowledge->getKnowledgesOfComplate($args);
	                $this->cache->set("allComplate".$user_id,$results);
	            }
                $newindex = $this->deDuplication($results);
                $info = $results[$newindex];
                array_splice($results, $newindex, 1); 
                $this->cache->set("allComplate".$user_id,$results);
                header('Content-Type:application/json; charset=utf-8');
                exit(json_encode($info,0));
            }
			$data['header'] = $this->load->controller('common/headerin');
	 		$data['footerin'] = $this->load->controller('common/footerin');
	 		$data['footer'] = $this->load->controller('common/footer');
	 		$this->response->setOutput($this->load->view('memory/knowledgeexam', $data));
		}
		public function deDuplication($array){
			$innerIndex = array_rand($array);
			return $innerIndex;
		}
	}
	
 ?>